import static org.junit.Assert.*;

import org.junit.Test;


public class TaskOrganizerTester {

	@Test
	public void testGetTasks() throws Exception {
		TaskOrganizer taskOrganizer = new TaskOrganizer();
		taskOrganizer.addNontimedTask("A", 90);
		taskOrganizer.addNontimedTask("B", 20);
		taskOrganizer.addNontimedTask("C", 82);
		taskOrganizer.addTimedTask("D", 19901127, 1800);
		taskOrganizer.addTimedTask("E", 19880912, 1818);
		taskOrganizer.addTimedTask("F", 19980828, 700);
		String[][] testNontimed = taskOrganizer.getNontimedTasks(83,3);
		String[][] testTimed = taskOrganizer.getTimedTasks(19901010, 3);
				
		assertEquals(testNontimed[0][0],"1");
		assertEquals(testNontimed[0][1],"C");
		assertEquals(testNontimed[0][2],"82");
		assertEquals(testNontimed[1][0],"2");
		assertEquals(testNontimed[1][1],"B");
		assertEquals(testNontimed[1][2],"20");
		assertEquals(testNontimed[2][0],null);
		assertEquals(testNontimed[2][1],null);
		assertEquals(testNontimed[2][2],null);
		
		assertEquals(testTimed[0][0],"1");
		assertEquals(testTimed[0][1],"D");
		assertEquals(testTimed[0][2],"19901127");
		assertEquals(testTimed[0][3],"1800");
		assertEquals(testTimed[1][0],"2");
		assertEquals(testTimed[1][1],"F");
		assertEquals(testTimed[1][2],"19980828");
		assertEquals(testTimed[1][3],"0700");
		assertEquals(testTimed[2][0],null);
		assertEquals(testTimed[2][1],null);
		assertEquals(testTimed[2][2],null);
		assertEquals(testTimed[2][3],null);

		taskOrganizer.editNontimed(1, "C new", 84);
		taskOrganizer.editNontimed(2, "B new", 75);
		taskOrganizer.editTimed(0, "E new", 20000101, 500);
		taskOrganizer.editTimed(2, "F new", 19970202, 1900);		
		testNontimed = taskOrganizer.getNontimedTasks(83,3);
		testTimed = taskOrganizer.getTimedTasks(19901010, 3);
		
		assertEquals(testNontimed[0][0],"2");
		assertEquals(testNontimed[0][1],"B new");
		assertEquals(testNontimed[0][2],"75");
		assertEquals(testNontimed[1][0],null);
		assertEquals(testNontimed[1][1],null);
		assertEquals(testNontimed[1][2],null);
		assertEquals(testNontimed[2][0],null);
		assertEquals(testNontimed[2][1],null);
		assertEquals(testNontimed[2][2],null);
		
		assertEquals(testTimed[0][0],"0");
		assertEquals(testTimed[0][1],"D");
		assertEquals(testTimed[0][2],"19901127");
		assertEquals(testTimed[0][3],"1800");
		assertEquals(testTimed[1][0],"1");
		assertEquals(testTimed[1][1],"F new");
		assertEquals(testTimed[1][2],"19970202");
		assertEquals(testTimed[1][3],"1900");
		assertEquals(testTimed[2][0],"2");
		assertEquals(testTimed[2][1],"F");
		assertEquals(testTimed[2][2],"19980828");
		assertEquals(testTimed[2][3],"0700");

	}
	@Test
	public void test2(){
		TaskOrganizer taskOrganizer = new TaskOrganizer();
		assert(taskOrganizer.isValidTime(2359));
		assert(taskOrganizer.isValidTime(0000));
		assert(!taskOrganizer.isValidTime(2400));
		assert(taskOrganizer.isValidTime(0001));
		assert(!taskOrganizer.isValidTime(-0001));
		
		assert(!taskOrganizer.isValidDate(1950));
		assert(taskOrganizer.isValidDate(19901127));
		assert(taskOrganizer.isValidDate(19880912));
		assert(taskOrganizer.isValidDate(19980828));
		assert(!taskOrganizer.isValidDate(2100325));
		assert(!taskOrganizer.isValidDate(-1920325));
		assert(!taskOrganizer.isValidDate(18990101));
		assert(taskOrganizer.isValidDate(20080229)); //correct if leap year
		assert(!taskOrganizer.isValidDate(20090229));//false if not leap year
	}
	

}
